import $ from './library/jquery.js';
import cookie from './library/cookie.js';
import querystring from './library/querystring.js';
import Swiper from './library/Swiper.js';

const swiper = new Swiper('.swiper-container', {
  spaceBetween: 30,
  centeredSlides: true,
  autoplay: {
    delay: 2500,
    disableOnInteraction: false,
  },
  pagination: {
    el: '.swiper-pagination',
    clickable: true,
  },
});

$(function() {
  $('.tabs>ul>li').on('mouseenter', function() {
      let index = $('.tabs>ul>li').index(this);
      $('.menu-right>div').eq(index).addClass('display').siblings().removeClass('display');
  });
  $('.mm_box').on('mouseleave', function() {
    $('.menu-right>div').removeClass('display');
});
});

$.ajax({
  type: "get",
  url: "../../interface/getData.php",
  dataType: "json", 
}).then(function(data){
  
  let temp = '';
  data.forEach((elm,i)=>{
    let picture = JSON.parse(elm.picture);
    // console.log(picture);
    temp +=`<div>
                <a href="./goods.html?item=${elm.id}"><img src="../${picture[0].src}" alt=""></a>
            </div>
          `
  })
  $('.recom').html(temp);

  
}).catch(function(xhr){
  console.log(xhr);
});
